#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    setWindowTitle("SVG View");
    createMenu();
    svgWindow = new SvgWindow;
    setCentralWidget(svgWindow);

}
void MainWindow::createMenu(){
    QMenu* fileMenu = menuBar()->addMenu("文件");
    QAction * openAct = new QAction("打开", this);
    connect(openAct, SIGNAL(triggered()),this, SLOT(slotOpenFile()));
    fileMenu->addAction(openAct);
}

void MainWindow::slotOpenFile(){
    QString currentPath = QDir::currentPath();
    QString name = QFileDialog::getOpenFileName(this, "打开", currentPath,"SVG files(*.svg)");
    svgWindow->setFile(name);
}
MainWindow::~MainWindow()
{
    delete ui;
}

